<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <script>
    //es5面向对象-为了最大限度复用代码
    //1.声明构造函数-必须大写
 /*    function User(name1, pass1){
      this.name=name1;  //变量用this去定义-公有属性
      this.pass=pass1;
    }
    //2.构造函数加方法——给它加User.prototype
    User.prototype.showName=function (){
      console.log(this.name);
    };
    User.prototype.showPass=function (){
      console.log(this.pass);
    };
    //3.实例化
    var u1=new User('blue', '123456');

    u1.showName();
    u1.showPass(); */

    //es6面向对象
  class User{
      constructor(name1, pass1){ //constructor构造函数
        this.name=name1;  //变量用this去定义-公有属性
        this.pass=pass1;
      }
      
      //构造函数加方法——给它加User.prototype
      showName(){
       console.log(35,this.name);
      }
      showPass(){
       console.log(38,this.pass);
     }
  }
   
    var u1=new User('blue', '123456');

    u1.showName();
    u1.showPass();
    </script>
  </head>
  <body>

  </body>
</html>
